package com.hamster.crm.web;

import com.hamster.crm.pojo.OpinionaireResult;

import com.hamster.crm.service.OpinionaireResultService;
import com.hamster.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;


/**
 * 问卷调查结果的Controller
 * @author Tarry
 * @create 2019/12/23 13:10
 */
@RestController
@RequestMapping("opinionaireResult")
public class OpinionaireResultController {
    @Autowired
    private OpinionaireResultService opinionaireResultService;

    /**
     * 条件查询 问卷结果列表
     * @param pageSize 每页条数
     * @param currentPage 页码
     * @param title  问卷名称
     * @param name   员工姓名
     * @return PageResult<OpinionaireResult>
     */
    @GetMapping("list")
    public ResponseEntity<PageResult<OpinionaireResult>> listOpinionaireResults(
            @RequestParam(required=false) Integer pageSize,
            @RequestParam(required=false) Integer currentPage,
            @RequestParam(required = false)String title,
            @RequestParam(required = false) String name
    ){
        PageResult<OpinionaireResult> result = opinionaireResultService.listOpinionaireResults(pageSize,currentPage,title,name);
        return ResponseEntity.ok(result);
    }

    /**
     * 查询指定员工负责的客户的调查问卷的列表
     * @param opinionaireId 问卷id
     * @param employeeId 员工id
     * @return
     */
    @GetMapping("listDetail")
    public ResponseEntity<List<OpinionaireResult>> listDetails(@RequestParam String opinionaireId,@RequestParam String employeeId){
        List<OpinionaireResult> list = opinionaireResultService.listDetails(opinionaireId,employeeId);
        return ResponseEntity.ok(list);
    }

    /**
     * 根据问卷结果的id  查询问卷结果详情
     * @param id 问卷结果id
     * @return OpinionaireResult
     */
    @GetMapping("getDetail")
    public ResponseEntity<OpinionaireResult> getDetail (@RequestParam String id){
        OpinionaireResult opinionaireResult = opinionaireResultService.getDetail(id);
        return ResponseEntity.ok(opinionaireResult);
    }

}
